<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>1.下列关于readyState状态值，描述正确的选项是？（选择两项） |  zfy的个人博客</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="./img/Scorpio.png">
    <link rel="stylesheet" href="./css/style.css">
    <meta name="description" content="My tech blog">
    
    <link rel="preload" href="./assets/css/0.styles.cfdaa54c.css" as="style"><link rel="preload" href="./assets/js/app.7878252f.js" as="script"><link rel="preload" href="./assets/js/2.877879cc.js" as="script"><link rel="preload" href="./assets/js/96.8ed8b32f.js" as="script"><link rel="prefetch" href="./assets/js/10.a489e96f.js"><link rel="prefetch" href="./assets/js/11.f6f26a2f.js"><link rel="prefetch" href="./assets/js/12.8a827e29.js"><link rel="prefetch" href="./assets/js/13.e420b04a.js"><link rel="prefetch" href="./assets/js/14.52f00cc6.js"><link rel="prefetch" href="./assets/js/15.ef68d553.js"><link rel="prefetch" href="./assets/js/16.c2999dfd.js"><link rel="prefetch" href="./assets/js/17.0adb748c.js"><link rel="prefetch" href="./assets/js/18.2c077020.js"><link rel="prefetch" href="./assets/js/19.013b5e02.js"><link rel="prefetch" href="./assets/js/20.bb3b854e.js"><link rel="prefetch" href="./assets/js/21.28efc78c.js"><link rel="prefetch" href="./assets/js/22.4a1d71dd.js"><link rel="prefetch" href="./assets/js/23.605a5451.js"><link rel="prefetch" href="./assets/js/24.66bf035d.js"><link rel="prefetch" href="./assets/js/25.fbe72655.js"><link rel="prefetch" href="./assets/js/26.3f374d1f.js"><link rel="prefetch" href="./assets/js/27.556ea617.js"><link rel="prefetch" href="./assets/js/28.0cab868b.js"><link rel="prefetch" href="./assets/js/29.564f8747.js"><link rel="prefetch" href="./assets/js/3.4cfb1b9c.js"><link rel="prefetch" href="./assets/js/30.c4a099d1.js"><link rel="prefetch" href="./assets/js/31.7fbc3d2a.js"><link rel="prefetch" href="./assets/js/32.8f356b20.js"><link rel="prefetch" href="./assets/js/33.b5a1b0bb.js"><link rel="prefetch" href="./assets/js/34.57086c2e.js"><link rel="prefetch" href="./assets/js/35.2b4d0231.js"><link rel="prefetch" href="./assets/js/36.a99f6d64.js"><link rel="prefetch" href="./assets/js/37.eb25dcef.js"><link rel="prefetch" href="./assets/js/38.e45d8594.js"><link rel="prefetch" href="./assets/js/39.213e3a72.js"><link rel="prefetch" href="./assets/js/4.b86a0fbe.js"><link rel="prefetch" href="./assets/js/40.cadafdd6.js"><link rel="prefetch" href="./assets/js/41.23b0f26d.js"><link rel="prefetch" href="./assets/js/42.7c2b83c6.js"><link rel="prefetch" href="./assets/js/43.62f328ea.js"><link rel="prefetch" href="./assets/js/44.c4dfbd34.js"><link rel="prefetch" href="./assets/js/45.cde5bb22.js"><link rel="prefetch" href="./assets/js/46.6c62bdb8.js"><link rel="prefetch" href="./assets/js/47.4857766a.js"><link rel="prefetch" href="./assets/js/48.55a0cccc.js"><link rel="prefetch" href="./assets/js/49.3dceda91.js"><link rel="prefetch" href="./assets/js/5.13776f82.js"><link rel="prefetch" href="./assets/js/50.ab4d52fa.js"><link rel="prefetch" href="./assets/js/51.69ccc35a.js"><link rel="prefetch" href="./assets/js/52.01f3f711.js"><link rel="prefetch" href="./assets/js/53.c146a1ff.js"><link rel="prefetch" href="./assets/js/54.71ce70c2.js"><link rel="prefetch" href="./assets/js/55.98ef481d.js"><link rel="prefetch" href="./assets/js/56.b23daa51.js"><link rel="prefetch" href="./assets/js/57.6aa314ad.js"><link rel="prefetch" href="./assets/js/58.7d6367d9.js"><link rel="prefetch" href="./assets/js/59.88894cf5.js"><link rel="prefetch" href="./assets/js/6.93d89692.js"><link rel="prefetch" href="./assets/js/60.111f9a04.js"><link rel="prefetch" href="./assets/js/61.add82aab.js"><link rel="prefetch" href="./assets/js/62.8bfac830.js"><link rel="prefetch" href="./assets/js/63.db44a5ca.js"><link rel="prefetch" href="./assets/js/64.0244f0ef.js"><link rel="prefetch" href="./assets/js/65.2be994de.js"><link rel="prefetch" href="./assets/js/66.c5066e37.js"><link rel="prefetch" href="./assets/js/67.c11b474b.js"><link rel="prefetch" href="./assets/js/68.276bdc3e.js"><link rel="prefetch" href="./assets/js/69.f5f39d50.js"><link rel="prefetch" href="./assets/js/7.ca9f7e96.js"><link rel="prefetch" href="./assets/js/70.e3ca02b0.js"><link rel="prefetch" href="./assets/js/71.befcf8f7.js"><link rel="prefetch" href="./assets/js/72.04fabafd.js"><link rel="prefetch" href="./assets/js/73.e5b707f2.js"><link rel="prefetch" href="./assets/js/74.b5668150.js"><link rel="prefetch" href="./assets/js/75.eb7cfac9.js"><link rel="prefetch" href="./assets/js/76.c1b76370.js"><link rel="prefetch" href="./assets/js/77.5875e953.js"><link rel="prefetch" href="./assets/js/78.a5e2fa5b.js"><link rel="prefetch" href="./assets/js/79.eb2d51a7.js"><link rel="prefetch" href="./assets/js/8.570c39ea.js"><link rel="prefetch" href="./assets/js/80.7252ac50.js"><link rel="prefetch" href="./assets/js/81.eb980d26.js"><link rel="prefetch" href="./assets/js/82.9e069d8f.js"><link rel="prefetch" href="./assets/js/83.8c5a6dc6.js"><link rel="prefetch" href="./assets/js/84.26baaa09.js"><link rel="prefetch" href="./assets/js/85.96bc7e77.js"><link rel="prefetch" href="./assets/js/86.9c9dd1ca.js"><link rel="prefetch" href="./assets/js/87.d54639b8.js"><link rel="prefetch" href="./assets/js/88.3d3ae1e1.js"><link rel="prefetch" href="./assets/js/89.a81caa83.js"><link rel="prefetch" href="./assets/js/9.7a58df3d.js"><link rel="prefetch" href="./assets/js/90.c3c347ed.js"><link rel="prefetch" href="./assets/js/91.b6240032.js"><link rel="prefetch" href="./assets/js/92.8331718a.js"><link rel="prefetch" href="./assets/js/93.ca174cfa.js"><link rel="prefetch" href="./assets/js/94.fec3300c.js"><link rel="prefetch" href="./assets/js/95.076b06fb.js">
    <link rel="stylesheet" href="./assets/css/0.styles.cfdaa54c.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/./" class="home-link router-link-active"><!----> <span class="site-name"> zfy的个人博客</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="http://127.0.0.1:3002/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  自由博客板块
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="http://zfyangelo.gitee.io/yu-weather-web-show/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  天气预报
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="/./guide/" class="nav-link router-link-active">
  个人的学习笔记
</a></div><div class="nav-item"><a href="/./baodian/interview/" class="nav-link">
  项目及在校经历
</a></div><div class="nav-item"><a href="/./baodian/talk/" class="nav-link">
  爱好和联系方式
</a></div><div class="nav-item"><a href="https://gitee.com/zfyangelo" target="_blank" rel="noopener noreferrer" class="nav-link external">
  我的gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="http://127.0.0.1:3002/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  自由博客板块
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="http://zfyangelo.gitee.io/yu-weather-web-show/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  天气预报
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="/./guide/" class="nav-link router-link-active">
  个人的学习笔记
</a></div><div class="nav-item"><a href="/./baodian/interview/" class="nav-link">
  项目及在校经历
</a></div><div class="nav-item"><a href="/./baodian/talk/" class="nav-link">
  爱好和联系方式
</a></div><div class="nav-item"><a href="https://gitee.com/zfyangelo" target="_blank" rel="noopener noreferrer" class="nav-link external">
  我的gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>HTML</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>CSS</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>Javascipt</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>HTML&amp;CSS练习</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>Javascipt练习</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/./guide/notes/jswork/01-认识javascript.html" class="sidebar-link">01-认识javaScript</a></li><li><a href="/./guide/notes/jswork/02-变量与数据类型.html" class="sidebar-link">02-变量与数据类型</a></li><li><a href="/./guide/notes/jswork/03-DOM.html" class="sidebar-link">03-DOM</a></li><li><a href="/./guide/notes/jswork/04-表达式和操作符.html" class="sidebar-link">04-表达式和操作符</a></li><li><a href="/./guide/notes/jswork/05-判断.html" class="sidebar-link">05-判断</a></li><li><a href="/./guide/notes/jswork/06-循环.html" class="sidebar-link">06-循环</a></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>07-暂无</span> <span class="arrow right"></span></p> <!----></section></li><li><a href="/./guide/notes/jswork/08-函数.html" class="sidebar-link">08-函数</a></li><li><a href="/./guide/notes/jswork/09-案例.html" class="sidebar-link">09-案例</a></li><li><a href="/./guide/notes/jswork/10-数组.html" class="sidebar-link">10-数组</a></li><li><a href="/./guide/notes/jswork/11-字符串.html" class="sidebar-link">11-字符串</a></li><li><a href="/./guide/notes/jswork/12-DOM.html" class="sidebar-link">12-DOM</a></li><li><a href="/./guide/notes/jswork/13-浏览器操作.html" class="sidebar-link">13-BOM</a></li><li><a href="/./guide/notes/jswork/14-面向project.html" class="sidebar-link">14-面向对象</a></li><li><a href="/./guide/notes/jswork/15-Js阶段测试组卷.html" class="sidebar-link">15-Js阶段测试组卷</a></li><li><a href="/./guide/notes/jswork/16-模板字符串箭头函数变量声明.html" class="sidebar-link">16-模板字符串箭头函数变量声明</a></li><li><a href="/./guide/notes/jswork/17-解构赋值.html" class="sidebar-link">17-解构赋值</a></li><li><a href="/./guide/notes/jswork/18-project字面量增强和函数默认参数.html" class="sidebar-link">18-对象字面量增强和函数默认参数</a></li><li><a href="/./guide/notes/jswork/19-剩余参数和数组展开.html" class="sidebar-link">19-剩余参数和数组展开</a></li><li><a href="/./guide/notes/jswork/20-Map Set.html" class="sidebar-link">20-Map Set</a></li><li><a href="/./guide/notes/jswork/21-iterator和for...of循环.html" class="sidebar-link">21-iterator和for...of循环</a></li><li><a href="/./guide/notes/jswork/22-Promise和class.html" class="sidebar-link">22-Promise和class</a></li><li><a href="/./guide/notes/jswork/23-module.html" class="sidebar-link">23-module</a></li><li><a href="/./guide/notes/jswork/24-ES6测评题目.html" class="sidebar-link">24-ES6测评题目</a></li><li><a href="/./guide/notes/jswork/25-本地存储和http.html" class="sidebar-link">25-本地存储和http</a></li><li><a href="/./guide/notes/jswork/26-ajax选择题.html" class="active sidebar-link">26-ajax选择题</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h3 id="_1-下列关于readystate状态值-描述正确的选项是-选择两项"><a href="#_1-下列关于readystate状态值-描述正确的选项是-选择两项" class="header-anchor">#</a> 1.下列关于readyState状态值，描述正确的选项是？（选择两项）</h3> <p>**A.**状态值为0：此时尚未创建xhr对象，也没有调用open方法</p> <p>**B.**状态值为1：此时open方法已被调用，但是尚未调用send方法</p> <p>**C.**状态值为2：send方法已被调用，但是尚未接收到响应数据</p> <p>**D.**状态值为3：已经接收完响应数据了</p> <p><strong>本题主要考查readyState状态值表示的含义。</strong></p> <p>readyState状态值一共有5个值，分别代表的含义如下：</p> <p>0：未初始化，已经创建了xhr对象，但是尚未调用open方法。</p> <p>1：启动，open方法已被调用，但是尚未调用send方法。</p> <p>2：发送，send方法已被调用，但是尚未接收到响应数据。</p> <p>3：接收，已经接收到部分响应数据，还未接受完。</p> <p>4：完成，已经接收到全部响应数据。</p> <p>readyState值为0时，已经创建了xhr对象，A选项错误。</p> <p>根据前面对readyState状态值的解析可以BC选项正确。</p> <p>readyState值为3时，只接受到了部分响应数据，C选项错误。</p> <p><strong>所以本题答案为BC.</strong></p> <h3 id="_2-当readystate等于4之后-可以获取到响应数据的选项是-选择一项"><a href="#_2-当readystate等于4之后-可以获取到响应数据的选项是-选择一项" class="header-anchor">#</a> 2.当readyState等于4之后，可以获取到响应数据的选项是？（选择一项）</h3> <p>**A.**状态值为0：此时尚未创建xhr对象，也没有调用open方法</p> <p>**B.**状态值为1：此时open方法已被调用，但是尚未调用send方法</p> <p>**C.**状态值为2：send方法已被调用，但是尚未接收到响应数据</p> <p>**D.**状态值为3：已经接收完响应数据了</p> <p>参考解析：</p> <p><strong>本题考查正常获取响应数据的条件。</strong></p> <p>当满足xhr.status&gt;= 200 &amp;&amp; xhr.status &lt; 300或者满足xhr.status=== 304时，可以正常获取响应数据。</p> <p>A选项：xhr.status &gt; 300条件是错误的。</p> <p>C选项：xhr.status &lt;200 条件是错误的</p> <p>D选项： xhr.status&lt;=200 并且xhr.status&gt;300条件是错误的。</p> <p><strong>本题正确的选项是B</strong></p> <h3 id="_3-观察下图-代码中有几处错误-选择一项"><a href="#_3-观察下图-代码中有几处错误-选择一项" class="header-anchor">#</a> 3.观察下图，代码中有几处错误？（选择一项）</h3> <p><img src="https://i.loli.net/2020/12/15/qS941rClAHDLg5t.png" alt="image-20201215191209703"></p> <p>**A.**1处</p> <p>**B.**2处</p> <p>**C.**3处</p> <p>**D.**4处</p> <p><strong>本题考查Ajax的使用步骤。</strong></p> <p>Ajax请求可以分为四个步骤，第一步创建xhr 对象；第二步监听事件，处理响应；第三步准备发送请求；第四步发送请求。</p> <p>第一处错误：创建xhr 对象时单词写错，正确的写法为XMLHttpRequest</p> <p>第二处错误：绑定readystatechange事件时，没有加on，正确的写法为onreadystatechange</p> <p>第三处错误：获得字符串形式的响应数据，responseText的t小写了，正确的写法是responseText</p> <p>第四处错误：先使用了send方法，后使用open方法，正确的步骤是先使用open方法，后使用send方法。</p> <p><strong>一共有四处错误，本题正确的选项是D</strong></p> <h3 id="_4-下列json数据-格式书写正确的选项是-选择一项"><a href="#_4-下列json数据-格式书写正确的选项是-选择一项" class="header-anchor">#</a> 4.下列json数据，格式书写正确的选项是？（选择一项）</h3> <p><strong>A.</strong></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token punctuation">{</span>
    <span class="token string-property property">&quot;username&quot;</span> <span class="token operator">:</span> <span class="token string">&quot;xm&quot;</span><span class="token punctuation">,</span><span class="token comment">//用户名</span>
    <span class="token string-property property">&quot;age&quot;</span><span class="token operator">:</span> <span class="token number">18</span><span class="token comment">//年龄</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><strong>B.</strong></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token punctuation">{</span>
    <span class="token string-property property">' username '</span> <span class="token operator">:</span> <span class="token string">'xm'</span><span class="token punctuation">,</span>
      <span class="token string-property property">'age'</span> <span class="token operator">:</span> <span class="token number">16</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><strong>C.</strong></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token punctuation">{</span>
    <span class="token string-property property">&quot;username&quot;</span> <span class="token operator">:</span><span class="token string">&quot;xm&quot;</span><span class="token punctuation">,</span>
     <span class="token string-property property">&quot;age&quot;</span> <span class="token operator">:</span> <span class="token string">&quot;undefined&quot;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><strong>D.</strong></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token punctuation">{</span>
    <span class="token literal-property property">username</span> <span class="token operator">:</span><span class="token string">&quot;xm&quot;</span><span class="token punctuation">,</span>
    <span class="token literal-property property">age</span><span class="token operator">:</span> <span class="token number">18</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><strong>本题主要考查JSON格式。</strong></p> <p>JSON格式必须满足以下几个条件：</p> <p>1、JSON中的字符串必须使用双引号。</p> <p>2、JSON中没有undefined值，使用时要用引号包裹起来。</p> <p>3、JSON中不能添加注释。</p> <p>代码中添加了注释，不符合条件，A选项错误。</p> <p>代码中字符串使用单引号包裹，不符合条件，B选项错误。</p> <p>JSON中没有undefined值，但是代码中使用双引号包裹了undefined，属于字符串，C选项正确。</p> <p>代码中没有使用双引号包裹属性名，属于对象格式的写法，而不是JSON格式，D选项错误。</p> <p><strong>所以本题答案为C.</strong></p> <h3 id="_5-下列选项中-描述错误的是-选择一项"><a href="#_5-下列选项中-描述错误的是-选择一项" class="header-anchor">#</a> 5.下列选项中，描述错误的是？（选择一项）</h3> <p>**A.**JSON.stringify()的作用是将 JavaScript 对象转换为JSON字符串</p> <p>**B.**JSON.stringify()方法让localStorage/sessionStorage可以存储对象</p> <p>**C.**JSON.parse()作用是将字符串转为一个对象</p> <p>**D.**JSON.stringify()方法可以判断两个数组或对象中的值是否相等</p> <p>参考解析：</p> <p><strong>本题主要考查JSON的常用方法。</strong></p> <p>JSON中常用的方法是stringify和parse。</p> <p>JSON.stringify()的作用是将 JavaScript 对象转换为JSON字符串，A选项正确。</p> <p>JSON.stringify()方法让localStorage/sessionStorage可以存储对象，B选项正确。</p> <p>JSON.parse()作用是将JSON字符串转为一个对象，字符串必须符合JSON格式，即键值都必须使用双引号包裹，而不是说任意一个字符串就可以使用JSON.parse方法转成字符串。C选项错误。</p> <p>两个对象（或数组），值相同，由于地址不同，直接比较是不相等的，而使用JSON.stringify方法将对象（或数组）转成字符串之后，就可以只比较值了，D选项正确。示例：</p> <h3 id="_6-下列描述正确的选项是-选择两项"><a href="#_6-下列描述正确的选项是-选择两项" class="header-anchor">#</a> 6.下列描述正确的选项是？（选择两项）</h3> <p>**A.**responseType属性值为空时，不可以使用reponse属性接收</p> <p>**B.**responseType属性值为json时，不可以使用reponseText属性接收</p> <p>**C.**responseType属性值为text时，只能使用reponseText属性接收</p> <p>**D.**没有设置reponseType属性时，可以使用reponseText或reponse属性接收</p> <p><strong>本题主要考查reponseText和reponse属性</strong>。</p> <p>满足以下三个条件中的任意一个，才可以使用reponseText接收响应的数据。</p> <p>（1）没有设置reponseType。</p> <p>（2）reponseType = “”</p> <p>（3）reponseType = “text”</p> <p>不管reponseType设置任意值，都可以使用reponse接收响应的数据。</p> <p>responseType属性值为空时，可以使用reponse属性接收， A选项错误。</p> <p>responseType属性值为json时，不满足条件，所以不可以使用reponseText属性接收。B选项正确。</p> <p>responseType属性值为text时，reponseText和reponse属性都可以接收，C选项错误。</p> <p>没有设置reponseType属性时，可以使用reponseText或reponse属性接收，D选项正确。</p> <p><strong>所以本题答案为BD.</strong></p> <h3 id="_7-地址为http-www-baidu-com的页面-向下列哪个地址发送请求时-不属于跨域的是-选择一项"><a href="#_7-地址为http-www-baidu-com的页面-向下列哪个地址发送请求时-不属于跨域的是-选择一项" class="header-anchor">#</a> 7.地址为http://www.baidu.com的页面， 向下列哪个地址发送请求时，不属于跨域的是？（选择一项）</h3> <p>**A.**http://www.baidu.com:8080</p> <p>**B.**http://www.m.baidu.com</p> <p>**C.**https://www.baidu.com/less</p> <p>**D.**http://www.baidu.com/course/list</p> <p><strong>本题主要考查“域”的概念。</strong></p> <p>http（协议）😕/class.imooc.com（域名）:443(端口号)/course（路径），当协议、域名和端口号，任何一个不一样，就是不同域， 与路径无关。</p> <p>http://www.imooc.com和http://www.imooc.com:8080端口号不同，A选项错误。</p> <p>www.imooc.com和www.m.imooc.com 域名不同，B选项错误。</p> <p>http和https协议不同，C选项错误。</p> <p>只要协议、域名和端口号相同，就属于同一个域，不受路径影响，D选项正确。</p> <p><strong>所以本题答案为D.</strong></p> <h3 id="_8-如果想要发送json格式的数据-setrequestheader-和send-方法该如何设置-选择一项"><a href="#_8-如果想要发送json格式的数据-setrequestheader-和send-方法该如何设置-选择一项" class="header-anchor">#</a> 8.如果想要发送json格式的数据，setRequestHeader()和send()方法该如何设置？（选择一项）</h3> <p><strong>A.</strong><img src="https://i.loli.net/2020/12/15/eGfWdJp3scTOPHi.png" alt="image-20201215192352467"></p> <p><strong>B.</strong><img src="https://i.loli.net/2020/12/15/GIav9T8yj4mhkPJ.png" alt="image-20201215192401262"></p> <p><strong>C.</strong><img src="https://i.loli.net/2020/12/15/2ZVqQ4ONreTkYwa.png" alt="image-20201215192412482"></p> <p><strong>D.</strong><img src="https://i.loli.net/2020/12/15/t3s9Cb4QOKYzE8B.png" alt="image-20201215192424503"></p> <p><strong>本题考查使用setRequestHeader()和send()方法，来发送json格式的数据</strong></p> <p>setRequestHeader()方法中，Content-Type设置为application/x-www-form-urlencoded，表示要发送名值对格式的数据，send()方法中，写成username=alex&amp;age=18格式。BC不符合题意。</p> <p>Content-Type设置为application/json，表示要发送json格式的数据</p> <p>send()方法中，数据需要使用JSON.stringify()方法转换一下。</p> <p><strong>本题正确的选项是D</strong></p></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/./guide/notes/jswork/25-本地存储和http.html" class="prev">
        25-本地存储和http
      </a></span> <!----></p></div> </main></div><div class="global-ui"><!----><div class="reco-bgm-panel" data-v-b1d3339e><audio id="bgm" src="https://www.ytmp3.cn/down/75475.mp3" data-v-b1d3339e></audio> <div class="reco-float-box" style="bottom:30px;z-index:999999;display:none;" data-v-b1d3339e data-v-41bcba48 data-v-b1d3339e><img src="https://p1.music.126.net/qTSIZ27qiFvRoKj-P30BiA==/109951165895951287.jpg?param=200y200" data-v-b1d3339e></div> <div class="reco-bgm-box" style="left:10px;bottom:10px;z-index:999999;" data-v-b1d3339e data-v-41bcba48 data-v-b1d3339e><div class="reco-bgm-cover" style="background-image:url(https://p1.music.126.net/qTSIZ27qiFvRoKj-P30BiA==/109951165895951287.jpg?param=200y200);" data-v-b1d3339e><div class="mini-operation" style="display:none;" data-v-b1d3339e><i class="reco-bgm reco-bgm-pause" style="display:none;" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-play" style="display:none;" data-v-b1d3339e></i></div> <div class="falut-message" style="display:none;" data-v-b1d3339e>
          播放失败
        </div></div> <div class="reco-bgm-info" data-v-b1d3339e data-v-41bcba48 data-v-b1d3339e><div class="info-box" data-v-b1d3339e><i class="reco-bgm reco-bgm-music music" data-v-b1d3339e></i>花花公子</div> <div class="info-box" data-v-b1d3339e><i class="reco-bgm reco-bgm-artist" data-v-b1d3339e></i>马思唯/step.jad</div> <div class="reco-bgm-progress" data-v-b1d3339e><div class="progress-bar" data-v-b1d3339e><div class="bar" data-v-b1d3339e></div></div></div> <div class="reco-bgm-operation" data-v-b1d3339e><i class="reco-bgm reco-bgm-last last" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-pause pause" style="display:none;" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-play play" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-next next" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-volume1 volume" data-v-b1d3339e></i> <i class="reco-bgm reco-bgm-mute mute" style="display:none;" data-v-b1d3339e></i> <div class="volume-bar" data-v-b1d3339e><div class="bar" data-v-b1d3339e></div></div></div></div> <div class="reco-bgm-left-box" data-v-b1d3339e data-v-41bcba48 data-v-b1d3339e><i class="reco-bgm reco-bgm-left" data-v-b1d3339e></i></div></div></div></div></div>
    <script src="./assets/js/app.7878252f.js" defer></script><script src="./assets/js/2.877879cc.js" defer></script><script src="./assets/js/96.8ed8b32f.js" defer></script>
  </body>
</html>
